﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace QLBV
{
    public partial class index : System.Web.UI.Page
    {
        SqlConnection conn;
        String strConn="Data Source=HTD-COM;Initial Catalog=QLBV;Integrated Security=True;Pooling=False";
        String user="";
        protected void Page_Load(object sender, EventArgs e)
        {
         //   txtName.Text=Session["Dang nhap"].ToString();
           // txtAddress.Text = Session["User"].ToString();
           if(Session["Dang nhap"]=="1")
              user=Session["User"].ToString();
            conn = new SqlConnection(strConn);
            conn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Select *  from Users Where Username= '"+user+"'";
            SqlDataReader reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                txtName.Text = reader.GetValue(3).ToString();
                txtAddress.Text = reader.GetValue(6).ToString();
                txtAge.Text = reader.GetValue(5).ToString();
                txtGender.Text = reader.GetValue(4).ToString();
                txtPhone.Text = reader.GetValue(7).ToString();
            }
       //     else lbMsg.Text = "Không có bệnh nhân mà bạn tìm kiếm!";
            reader.Close();
            conn.Close();
        }
    }
}